package sarahstools;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtils {

	private static Calendar cal = Calendar.getInstance();
	
	public static Date incDay(Date datum, int count)
	{
		cal.setTime(datum);
		cal.add(Calendar.DATE, count);
		
		return cal.getTime();
	}
	
	public static int getDayOfWeek(Date datum)
	{
		cal.setTime(datum);
		int tmpday = cal.get(Calendar.DAY_OF_WEEK) - 2;
		if (tmpday == -1)
			return 6;
		else
			return tmpday;
	}
	
	public static Date parseDate(String datum) throws ParseException
	{
		return new SimpleDateFormat("dd.MM.yyyy").parse(datum);
	}
	
	public static String formatDate(Date datum)
	{
		return new SimpleDateFormat("dd.MM.yyyy").format(datum);
	}
}
